#include<iostream>
using namespace std;
int n;
int start=1;
int fruit[200002];
bool vis[200002],flag=true;
int main()
{
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>fruit[i];
	while(flag)
	{
		flag=false;
		for(int i=1;i<=n;i++)
		{
			if(fruit[start]!=fruit[i]&&!vis[i])
			{
				vis[start]=true;
				cout<<start<<" ";
				start=i;
			}
		}
		vis[start]=true;
		cout<<start<<" ";
		for(int i=1;i<=n;i++)
		{
			if(!vis[i])
			{
				flag=true;
				start=i;
				break;
			}
		}
		cout<<endl;
	}
	fclose(stdin);
	fclose(stdout);
}
